<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8" %>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%
    String ctx = request.getContextPath();
    request.setAttribute("ctx", ctx);
%>
<html>
<head>
    <title>Title</title>
    <script src="${ctx}/bootstrap/jquery-1.9.1.min.js"></script>
    <script src="${ctx}/bootstrap/bootstrap.js"></script>
    <script src="${ctx}/bootstrap/jquery.validate.min.js"></script>
    <script src="${ctx}/bootstrap/messages_zh.js"></script>
    <script src="${ctx}/bootstrap/validate.js"></script>
    <link rel="stylesheet" href="css/index_work.css">
</head>
<body>
<form action="${ctx}/add.do">
    <input type="hidden" name="did" value="${dianpu.did}">
    店铺名称:<input type="text" name="dname" value="${dianpu.dname}"><br>
    创建日期<input type="date" name="create_date" value="${dianpu.create_date}"><br>
    图片：<input type="file" name="file"> <img src="${dianpu.img}" style="width: 20px;height: 20px"><br>
    销售商店
    <div id="ses">

    </div>
    <input type="submit" value="提交">
</form>
</body>
<script>
    $(function () {
        $.post("${ctx}/getshop.do",function (res) {
            for (let x in res) {
                $("#ses").append('<input type="checkbox" name="sids" value="'+res[x].sid+'">'+res[x].sname)
            }
            <c:forEach items="${dianpu.shops}" var="var">
              $("[name='sids'][value='${var.sid}']").prop("checked",true);
            </c:forEach>
        })
    })
</script>
</html>
